<?php

/**
 * Contact filter form base class.
 *
 * @package    Porba
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseContactFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'contact_code'   => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'name'           => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'contact_person' => new sfWidgetFormFilterInput(),
      'address'        => new sfWidgetFormFilterInput(),
      'zipcode'        => new sfWidgetFormFilterInput(),
      'city'           => new sfWidgetFormFilterInput(),
      'country'        => new sfWidgetFormFilterInput(),
      'phone'          => new sfWidgetFormFilterInput(),
      'mobile'         => new sfWidgetFormFilterInput(),
      'fax'            => new sfWidgetFormFilterInput(),
      'email'          => new sfWidgetFormFilterInput(),
      'website'        => new sfWidgetFormFilterInput(),
      'bank'           => new sfWidgetFormFilterInput(),
      'bank_account'   => new sfWidgetFormFilterInput(),
      'IBAN'           => new sfWidgetFormFilterInput(),
      'BIC'            => new sfWidgetFormFilterInput(),
      'VAT'            => new sfWidgetFormFilterInput(),
      'category_name'  => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('CategoryContact'), 'add_empty' => true)),
      'note'           => new sfWidgetFormFilterInput(),
      'created_at'     => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'updated_at'     => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
    ));

    $this->setValidators(array(
      'contact_code'   => new sfValidatorPass(array('required' => false)),
      'name'           => new sfValidatorPass(array('required' => false)),
      'contact_person' => new sfValidatorPass(array('required' => false)),
      'address'        => new sfValidatorPass(array('required' => false)),
      'zipcode'        => new sfValidatorPass(array('required' => false)),
      'city'           => new sfValidatorPass(array('required' => false)),
      'country'        => new sfValidatorPass(array('required' => false)),
      'phone'          => new sfValidatorPass(array('required' => false)),
      'mobile'         => new sfValidatorPass(array('required' => false)),
      'fax'            => new sfValidatorPass(array('required' => false)),
      'email'          => new sfValidatorPass(array('required' => false)),
      'website'        => new sfValidatorPass(array('required' => false)),
      'bank'           => new sfValidatorPass(array('required' => false)),
      'bank_account'   => new sfValidatorPass(array('required' => false)),
      'IBAN'           => new sfValidatorPass(array('required' => false)),
      'BIC'            => new sfValidatorPass(array('required' => false)),
      'VAT'            => new sfValidatorPass(array('required' => false)),
      'category_name'  => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('CategoryContact'), 'column' => 'name')),
      'note'           => new sfValidatorPass(array('required' => false)),
      'created_at'     => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'updated_at'     => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
    ));

    $this->widgetSchema->setNameFormat('contact_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Contact';
  }

  public function getFields()
  {
    return array(
      'id'             => 'Number',
      'contact_code'   => 'Text',
      'name'           => 'Text',
      'contact_person' => 'Text',
      'address'        => 'Text',
      'zipcode'        => 'Text',
      'city'           => 'Text',
      'country'        => 'Text',
      'phone'          => 'Text',
      'mobile'         => 'Text',
      'fax'            => 'Text',
      'email'          => 'Text',
      'website'        => 'Text',
      'bank'           => 'Text',
      'bank_account'   => 'Text',
      'IBAN'           => 'Text',
      'BIC'            => 'Text',
      'VAT'            => 'Text',
      'category_name'  => 'ForeignKey',
      'note'           => 'Text',
      'created_at'     => 'Date',
      'updated_at'     => 'Date',
    );
  }
}
